package com.mbl.base.modular.mall.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mbl.base.core.common.controller.BaseController;
import com.mbl.base.modular.config.entity.Dict;
import com.mbl.base.modular.mall.entity.Category;
import com.mbl.base.modular.mall.service.ICategoryService;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 类目表 前端控制器
 * </p>
 *
 * @author lwj
 * @since 2020-02-27
 */
@RestController
@RequestMapping("/mall/category")
public class CategoryController extends BaseController<Category, ICategoryService> {
    @Override
    public void machiningListResult(IPage<Category> page1) {
        final List<Category> records = page1.getRecords();
        records.forEach(dict -> {
            final List<Category> list = getService().query().eq("pid", dict.getId()).list();
            dict.setChildren(list);
        });
    }
}

